<template>
  <view>
    <quick-button></quick-button>
    <home v-if="showPage('常规版', 0)"></home>
    <user ref="user" v-if="showPage('常规版', 1)"></user>
    <HomeCaringVersion v-if="showPage('关怀版', 0)"></HomeCaringVersion>
    <userCaringVersion v-if="showPage('关怀版', 1)"></userCaringVersion>
    <u-tabbar :value="tabbarValue" @change="onTabbarChange" :safeAreaInsetBottom="false" style="z-index: 999;">
      <u-tabbar-item text="医家养">
        <image class="u-page__item__slot-icon" slot="inactive-icon" src="/static/feixiang/tarbar/application.png">
        </image>
        <image class="u-page__item__slot-icon" slot="active-icon" src="/static/feixiang/tarbar/application-active.png">
        </image>
      </u-tabbar-item>
      <!-- 		<u-tabbar-item text="资讯" @click="goMsg">
				<image class="u-page__item__slot-icon" slot="inactive-icon"1
					src="/static/feixiang/tarbar/application.png"></image>
				<image class="u-page__item__slot-icon" slot="active-icon"
					src="/static/feixiang/tarbar/application-active.png"></image>
			</u-tabbar-item> -->
      <u-tabbar-item text="我的">
        <image class="u-page__item__slot-icon" slot="inactive-icon" src="/static/feixiang/tarbar/user.png"></image>
        <image class="u-page__item__slot-icon" slot="active-icon" src="/static/feixiang/tarbar/user-active.png"></image>
      </u-tabbar-item>
    </u-tabbar>
  </view>
</template>
<script>
import Home from '../feixiang/home/Home';
import user from '../feixiang/user/user';
import HomeCaringVersion from '../feixiangCaringVersion/home/Home';
import userCaringVersion from '../feixiangCaringVersion/user/user';
export default {
  components: {
    Home,
    user,
    HomeCaringVersion,
    userCaringVersion
  },
  onLoad() {
    this.appStatus = uni.getStorageSync('app_status_key') || '常规版';
    const index = uni.getStorageSync('nav_to_index_index') || 0;
    this.onTabbarChange(parseInt(index));
    uni.removeStorageSync('nav_to_index_index');
  },
  onShow() {
    // if (this.tabbarValue == 1) {
    // 	this.tabbarValue = 0
    // }
    uni.showShareMenu({
      withShareTicket: true
    });
  },
  data() {
    return {
      tabbarValue: 0,
      appStatus: '',
      titles: ['医家养', '用户中心']
    };
  },
  methods: {
    refreshUser() {
      this.$refs.user._getUserMessage();
    },
    onTabbarChange(e) {
      this.tabbarValue = e;
      if (e !== 1) {
        uni.setNavigationBarTitle({
          title: this.titles[e]
        });
      }
    },
    showPage(name, index) {
      if (this.appStatus === name) {
        return index === this.tabbarValue;
      }
      return false;
    },
    goMsg() {
      uni.navigateTo({
        url: '/pages/message/message'
      });
    },
    onShareAppMessage() {
      return {
        title: '分享给朋友',
        path: '/pages/index/index'
      };
    },
    onShareTimeline() {
      return {
        title: '分享给朋友圈',
        path: '/pages/index/index'
      };
    }
  }
};
</script>

<style></style>
